<?php
    @include_once("conn.php");
    @include_once("./common.php");  
    header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, x-file-name");


    // 接收前端传过来的用户名和密码
    // $user = "a123123";
    // $pwd = "123123";

    $user = $_POST["user"];
    $pwd = $_POST["pwd"];


    if(!($user&&$pwd)){
        argErr();
    }

  
    $search = "select * from `userinfo` where user = '$user'";

    $result = mysqli_query($conn,$search);

    $item = mysqli_fetch_assoc($result);

    // print_r($item);

    $obj = array();
    if($item){   // 存在数据  => 判断密码
      
        $realPwd = $item["pwd"];   //数据库中真正的

        if($pwd == $realPwd){
            $obj["status"] = true;
            $obj["detail"] = "登陆成功";
        }else{
            $obj["status"] = false;
            $obj["detail"] = "用户名或密码有误";
        }

    }else{ //  不存在数据  => 用户名未注册
        $obj["status"] = false;
        $obj["detail"] = "该用户未注册";
    }

    echo json_encode($obj);
 

?>